//
//  DataBaseOperator.h
//  MarketDataColloctor
//
//  Created by jiro on 10/01/14.
//  Copyright 2010 jiro music. All rights reserved.
//

#import <Cocoa/Cocoa.h>

#import "libpq-fe.h"
#import <vector>

//	DBのレスポンス種別の定義（アプリ用の簡易定義）
enum DbResponseType
{
	DbResponse_Success,
	
	DbResponse_SuccessWithWarning,
	
	DbResponse_Fail,
	
	DbResponse_Unknown,

};

@interface DbOperator : NSObject {

	PGconn* dbConnection;

  	NSString* errorMessage;
}

+ (DbOperator*) defaultOperator;

- (id) init;

- (BOOL) connectToDb: (NSString*) dbName ofHost: (NSString*) host asUser: (NSString*) userName;

- (void) disconnect;

//	クエリを実行（クエリの内容は実行側で責任を持つ）
- (DbResponseType) executeQuery: (NSString*) query intoResult: (PGresult**) result;


//	PGresult instance is pqcleared in this method
- (DbResponseType) executeQueries: (const std::vector< NSString* >&) queries intoResults: (std::vector< PGresult* >&) results;

- (NSString*) errorMessage;

@end
